{{extend ('./layout.html')}} {{#block("body")}}
<!-- 列表内容 -->
<div class="panel panel-default">
    <div class="panel-heading">
        <ol class="breadcrumb">
            <li><a href="#">首页</a></li>
            <li><a href="#">视频</a></li>
            <li class="active">列表</li>
        </ol>
    </div>
    <div class="panel-heading">
        <div class="input-group">
            <span class="input-group-addon">视频标题</span>
            <input type="text" style="width:300px;margin-right:10px;" class="form-control" placeholder="请输入是查找的视频标题" id='search'>
            <input type="button" class="btn btn-primary" style="margin-right:10px;" id='searchBtn' value="查找">
            <input type="button" class="btn btn-primary" id="addId" onclick="window.location.href = '/video/add' " value="新增">
        </div>
    </div>
    <div class="panel-body">
        <div>
            <!-- 表格 -->
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>标题</th>
                        <th>排序号</th>
                        <th>视频Id</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {{#each(video)}}
                    <tr>
                        <td>{{this.vid}}</td>
                        <td>{{this.vtitle}}</td>
                        <td>{{this.vsortno}}</td>
                        <td>{{this.vvideoid}}</td>
                        <td>
                            <input type="button" class="btn btn-success" onclick="window.location.href = '/video/edit/{{this.vid}}'" value="编辑"> |
                            <input type="button" class="btn btn-danger" value="删除" onclick='del({{vid}})'>
                        </td>
                    </tr>
                    {{/each}}
                </tbody>
            </table>
        </div>
        <!-- 分页 -->
        <div>
            <nav>
                <ul class="pagination">
                    {{#if(currentPage===0)}}
                    <li class="disabled"><a href="javascript:;">«</a></li>
                    {{else}}
                    <li><a href="?pageSize={{pageSize}}&pageIndex={{currentPage-1}}&keyword={{keyword}}">«</a></li>
                    {{/if}} {{#each(list)}} {{#if(this===currentPage)}}
                    <li class="active"><a href="?pageSize={{pageSize}}&pageIndex={{this}}&keyword={{keyword}}">{{this+1}}</a></li>
                    {{else}}
                    <li><a href="?pageSize={{pageSize}}&pageIndex={{this}}&keyword={{keyword}}">{{this+1}}</a></li>
                    {{/if}} {{/each}} {{#if(currentPage===totalPage-1)}}
                    <li class="disabled"><a href="javascript:;">»</a></li>
                    {{else}}
                    <li><a href="?pageSize={{pageSize}}&pageIndex={{currentPage+1}}&keyword={{keyword}}">»</a></li>
                    {{/if}}
                </ul>
            </nav>
        </div>
    </div>
</div>
<script>
$('#searchBtn').on('click', function() {
    window.location.href = "?keyword=" + $('#search').val();
});
var del = function(id) {
    if (confirm('确定要删除？')) {
        $.getJSON('/video/del/' + id, function(json, textStatus) {
            alert(json.msg);
            if (json.state === 1) {
                window.location.reload();
            }
        });
    }

}
</script>
{{/block}}
